<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/jsf/template.xhtml">
    	<ui:define name="content">
    		
    		<h:form id="form">

    			<p:growl id="mensagem" showDetail="true" />

    			<!-- Opção PF/PJ -->
	    		<p:panel styleClass="panelSemBorda">
	    			<h:panelGrid columns="4" styleClass="panelSemBorda">
			    		<p:selectOneRadio id="opcaoPFouPJ" layout="custom" value="#{cadastroAnuncianteMB.anunciante.pfPj}">
			    			<f:selectItem itemLabel="PF" itemValue="1" />
			    			<f:selectItem itemLabel="PJ" itemValue="2" />
			    		</p:selectOneRadio>

			    		<h:panelGrid columns="4">
			    			<p:radioButton id="opt1" for="opcaoPFouPJ" onchange="panelPF.show();panelPJ.close();panelComum.show();panelComumNome.show()" itemIndex="0"></p:radioButton>
			    			<h:outputLabel for="opt1" value="PF" />
			    					
			    			<p:radioButton id="opt2" for="opcaoPFouPJ" onchange="panelPJ.show();panelPF.close();panelComum.show();panelComumNome.show()" itemIndex="1"></p:radioButton>
			    			<h:outputLabel for="opt2" value="PJ" />
			    		</h:panelGrid>
		    		</h:panelGrid>
	    		</p:panel>
	    		<!-- /Opção PF/PJ -->

	    		<!-- Comum_Nome -->
	    		<p:panel id="panelComumNome" widgetVar="panelComumNome" closable="true" toggleable="true" visible="false" styleClass="panelSemBorda">

	    			<h:panelGrid columns="1" cellpadding="5" >

	    				<h:outputText value="Nome: " />
		    			<p:inputText value="#{cadastroAnuncianteMB.anunciante.nome}" />

	    			</h:panelGrid>

	    		</p:panel>
	    		<!-- /Comum_Nome -->

	    		<!-- PF -->
	    		<p:panel id="panelPF" widgetVar="panelPF" closable="true" toggleable="true" visible="false" styleClass="panelSemBorda">

	    			<h:panelGrid columns="1" cellpadding="5" >

		    			<h:outputText value="CPF: " />
		    			<p:inputText value="#{cadastroAnuncianteMB.anunciante.cpf}" />

		    			<h:outputText value="RG: " />
		    			<p:inputText value="#{cadastroAnuncianteMB.anunciante.rg}" />

	    			</h:panelGrid>

	    		</p:panel>
	    		<!-- /PF -->

	    		<!-- PJ -->
	    		<p:panel id="panelPJ" widgetVar="panelPJ" closable="true" toggleable="true" visible="false" styleClass="panelSemBorda">

	    			<h:panelGrid columns="1" cellpadding="5" >

	    				<h:outputText value="Razão social: " />
		    			<p:inputText value="#{cadastroAnuncianteMB.anunciante.razaoSocial}" />

		    			<h:outputText value="CNPJ: " />
		    			<p:inputText value="#{cadastroAnuncianteMB.anunciante.cnpj}" />

	    			</h:panelGrid>

	    		</p:panel>
	    		<!-- /PJ -->

	    		<!-- Comum -->
	    		<p:panel id="panelComum" widgetVar="panelComum" closable="true" toggleable="true" visible="false" styleClass="panelSemBorda">

	    			<h:panelGrid columns="1" cellpadding="5" >

		    			<h:outputText value="Endereço: " />
			    		<p:inputText value="#{cadastroAnuncianteMB.anunciante.endereco}" />
			    		
			    		<h:outputText value="CEP: " />
			    		<p:inputText value="#{cadastroAnuncianteMB.anunciante.cep}" />
			    		
			    		<h:outputText value="Telefone: " />
			    		<p:inputText value="#{cadastroAnuncianteMB.anunciante.telefone}" />
			    		
			    		<h:outputText value="Contato: " />
			    		<p:inputText value="#{cadastroAnuncianteMB.anunciante.contato}" />

			    		<h:outputText value="Data de início do contrato: " />
			    		<p:calendar value="#{cadastroAnuncianteMB.anunciante.dataInicioContrato}" />
			    		
			    		<h:outputText value="Data de término do contrato: " />
			    		<p:calendar value="#{cadastroAnuncianteMB.anunciante.dataTerminoContrato}" />
			    		
			    		<h:outputText value="Dia de vencimento: " />
			    		<p:inputText type="number" value="#{cadastroAnuncianteMB.anunciante.diaVencimento}" />

			    		
		    			<!-- Lista de PDVs -->
		    			<p:dataTable var="listaPDV" value="#{cadastroAnuncianteMB.listaPDV}" rowKey="#{listaPDV.id}" selection="#{cadastroAnuncianteMB.anuncio.selecaoPDV}">
		    				<p:column selectionMode="multiple" style="width:2%"/>
		    				
		    				<p:column headerText="Nome PDV">
		    					<h:outputText value="#{listaPDV.nome}" />
		    				</p:column>

		    				<p:column headerText="Valor">
		    					<p:inputText value="#{listaPDV.valorAnuncioVolatil}" >
		    						<f:convertNumber type="number" maxFractionDigits="0"/>
		    					</p:inputText>
		    				</p:column>
		    			</p:dataTable>
		    			<!-- /Lista de PDVs -->

		    		</h:panelGrid>

		    		<h:panelGrid columns="2" cellpadding="5">

		    			<p:commandButton value="Cadastrar" styleClass="ui-priority-primary" actionListener="#{cadastroAnuncianteMB.cadastraAnunciante}" update="mensagem" />

		    		</h:panelGrid>

	    		</p:panel>
	    		<!-- /Comum -->

    		</h:form>
    	</ui:define>
    </ui:composition>

</html>